package com.zhanglijie.base.threadPool;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import javax.swing.SwingUtilities;

/**
 * @author zhanglijie
 * @version 1.0
 * @since 1.1.0 2022/7/3 0003 22:01
 */
public class RejectPolicyDemo {
    public static void main(String[] args) {
        ThreadPoolExecutor threadPool = new ThreadPoolExecutor(1,4,1, TimeUnit.SECONDS,new LinkedBlockingQueue<>(1));
        threadPool.setRejectedExecutionHandler(new MyRejectionPolicy());
        for (int i = 0; i < 10; i++) {
            threadPool.submit(()->{
                System.out.println(Thread.currentThread().getName()+"====>执行代码");
            });
        }

    }
}
